package com.yizhuoyan.his.webapi.controller.admin;

import com.yizhuoyan.his.ao.NoDrugChargeQueryAo;
import com.yizhuoyan.his.ao.NodrugChargeAddAo;
import com.yizhuoyan.his.ao.NodrugChargeModifyAo;
import com.yizhuoyan.his.dto.HosNodrugDto;
import com.yizhuoyan.his.dto.JSONResponse;
import com.yizhuoyan.his.service.admin.NodrugChargeManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 非药品收费项目Controller
 * author：ZJH
 */
@RestController
public class HosNodrugManageController {

    @Autowired
    NodrugChargeManageService nodrugChargeManageService;

    @PostMapping("/api/add-nodrug")
    public ResponseEntity<JSONResponse> addNodrug(NodrugChargeAddAo ao)throws Exception{
        nodrugChargeManageService.addNodrug(ao);
        return ResponseEntity.ok(JSONResponse.ok());
    }

    @DeleteMapping("/api/remove-nodrug/{id}")
    public ResponseEntity<JSONResponse> removeNodrug(@PathVariable Long id)throws Exception{
        nodrugChargeManageService.removeNodrug(id);
        return ResponseEntity.ok(JSONResponse.ok());
    }

    @PutMapping("/api/modify-nodrug/{id}")
    public ResponseEntity<JSONResponse> modifyNodrug(@PathVariable Long id, NodrugChargeModifyAo ao)throws Exception{
        nodrugChargeManageService.modifyNodrug(id,ao);
        return ResponseEntity.ok(JSONResponse.ok());
    }

    @GetMapping("/api/query-nodrug")
    public ResponseEntity<JSONResponse> queryNodrug(NoDrugChargeQueryAo ao)throws Exception{
        List<HosNodrugDto> hosNodrugDtos = nodrugChargeManageService.queryNodrug(ao);
        return ResponseEntity.ok(JSONResponse.ok(hosNodrugDtos));
    }
}
